#include "Solution.h"
#include <iostream>

using namespace std;

int main()
{
	int n;
	Solution s;
	while(cin>>n)
	{
		if(n==0)
			break;
		int a,b;
		cin>>a>>b;
		ListNode *head = NULL;
		ListNode* current = NULL;
		for(int i=0;i<n;i++)
		{
			if(!current)
			{
				head = current = new ListNode(0);
			}
			else
			{
				current->next = new ListNode(0);
				current = current->next;
			}
			cin>>current->val;
		}

		current = s.reverseBetween(head,a,b);
		while(current)
		{
			cout<<current->val<<" ";
			current = current->next;
		}		
		cout<<endl;
	}
}